<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<c-rt:if test="${!empty param.questionID || !empty param.id}">
	<c-rt:if test="${!empty param.questionID}">
		<c-rt:set var="questionID">${param.questionID}</c-rt:set>
	</c-rt:if> 
	<c-rt:if test="${!empty param.id}">
		<c-rt:set var="questionID">${param.id}</c-rt:set>
	</c-rt:if>
	
	<c-rt:set var="question" value="${pu:get('com.yaodian100.crm.cs.entity.Question', questionID)}"/>
</c-rt:if>
<c-rt:if test="${!empty question}">
${pu:reqSet('memberId', question.memberId) }
${pu:reqSet('orderId', question.extraValue['orderId'].value) }
${pu:reqSet('isProductQAA', question.extraValue['isProductQAA'].value) }
${pu:reqSet('returnId', question.extraValue['returnId'].value) }
${pu:reqSet('changeId', question.extraValue['changeId'].value) }
${pu:reqSet('channel', question.channel.description) }

${pu:reqSet('phone', question.extraValue['phone'].value) }
${pu:reqSet('phoneArea', question.extraValue['phoneArea'].value) }
${pu:reqSet('phoneExt', question.extraValue['phoneExt'].value) }
${pu:reqSet('mobile', question.extraValue['mobile'].value) }
${pu:reqSet('email', question.extraValue['email'].value) }
</c-rt:if>
<c-rt:if test="${empty question}">
	${pu:reqSet('memberId', param.memberId) }
	${pu:reqSet('orderId', param.orderId) }
	${pu:reqSet('isProductQAA', param.isProductQAA) }
	${pu:reqSet('returnId', param.returnId) }
	${pu:reqSet('changeId', param.changeId) }
	${pu:reqSet('channel', param.channel) }	
	<c-rt:if test="${!empty param.memberId}">
		${pu:reqSet('member', pu:get('com.yaodian100.ec.member.entity.Member', param.memberId)) }
		${pu:reqSet('phone', member.homePhone)}
		${pu:reqSet('phoneArea', '') }
		${pu:reqSet('phoneExt', '') }
		${pu:reqSet('mobile', member.mobile) }
		${pu:reqSet('email', member.email) }
	</c-rt:if>		
	
</c-rt:if>
<c-rt:set var="questionType" value="CommonQuestion"/>
<c-rt:set var="qt" value="${pu:get('com.yaodian100.crm.cs.entity.QuestionType', questionType)}"/>
<c-rt:set var="fromChannels" value="${pu:queryByHql('from FromChannel', null, null)}"/>

<script>
		$(document).ready( function() {
			$('.submit_button').click(function(){
				doAR('<%=application.getContextPath() %>/cs/saveBatchWorkOrder.do', 'main', 'theForm');
			});
		});	
		function submitForm(responser, workFlowNodeId){
			document.theForm.responser.value=responser;
			document.theForm.workFlowNodeId.value=workFlowNodeId;
			doAR('<%=application.getContextPath() %>/cs/saveBatchWorkOrder.do', 'main', 'theForm');
		}
		function submitForwardForm(type, responser, workFlowNodeId){
			document.theForm.workFlowNodeId.value=workFlowNodeId;
			document.theForm.submit();
		}
	
	
		
</script>

<br/>
<h1>批次新增工单</h1>

<c-rt:if test="${!empty param.operation}">
<c-rt:if test="${empty question}">
共读取到${readOrders }笔资料。<br>
${failBatch }笔读取订单资料失败。<br>
${successBatch }张订单已成功成立工单！<br>
</c-rt:if>
<c-rt:if test="${!empty question}">
已储存修改！
</c-rt:if>
</c-rt:if>
<form method="post" id="theForm" name="theForm" action="<%=application.getContextPath() %>/cs/saveBatchWorkOrder.do">
<input type="hidden" name="questionType" value="${questionType}"/>
<input type="hidden" name="workFlowNodeId" value="${workFlowNodeId}"/>

<c-rt:if test="${empty question}">
<input type="hidden" name="operation" value="save"/>
</c-rt:if>
<c-rt:if test="${!empty question}">
<input type="hidden" name="operation" value="update"/>
</c-rt:if>
<table class="tb-data" width="100%">
<tr>
<th width="130">订单编号</th>
<td><textarea id="batchOrderList" name="batchOrderList" rows="10" cols="50"/></textarea>
(每行一个订单编号)
</td>

</tr>

<c-rt:forEach items="${qt.extraAttr.attributes }" var="attr" varStatus="status">
<c-rt:if test="${attr.name=='class1'||attr.name=='class2'||attr.name=='commonQuestionType'}">
	<tr>
		<th>${attr.description }
		<c-rt:if test="${attr.dataType=='Component'}">
				<c-rt:if test="${attr.name=='class1'}">
				<script>
					$(function(){
						doAR('${attr.componentUrl}&class1=${question.extraValue[attr.name].value}&questionId=${question.id}', '${attr.name }Zone');
					});
				</script>
				</c-rt:if>
				<c-rt:if test="${attr.name=='class2'}">
				<script>
					$(function(){
						doAR('${attr.componentUrl}&class2=${question.extraValue[attr.name].value}&parentId=${question.extraValue["class1"].value}', '${attr.name }Zone');
					});
				</script>
				</c-rt:if>
				<c-rt:if test="${attr.name=='commonQuestionType'}">
				<script>
					$(function(){
						doAR('${attr.componentUrl}&commonQuestionType=${question.extraValue[attr.name].value}&parentId=${question.extraValue["class2"].value}', '${attr.name }Zone');
					});
				</script>
				</c-rt:if>
				<c-rt:if test="${attr.name=='mustInquire'}">
				
				<script>
					$(function(){
						doAR("${attr.componentUrl}&cqtId=${question.extraValue['commonQuestionType'].value}&mustInquire=${question.extraValue[attr.name].value}", '${attr.name }Zone');
					});
				</script>
				</c-rt:if>

		</c-rt:if>
		</th>
		
		<c-rt:if test="${attr.dataType=='Component'}">
			<td id="${attr.name }Zone">
				
			</td>
		</c-rt:if>
		
		
		
	</tr>
</c-rt:if>
</c-rt:forEach>
<tr><th>处理等级</th><td>
			<select name="priority">
				<option value="0">函件</option>
				<option value="1">一般件</option>
				<option value="2">急件</option>
				<option value="3">特急件</option>
			</select>
		</td></tr>

<tr>
	<th>立单原因描述
	</th>
	<td>
	<textarea name="description"></textarea>
	<div id="mustInquireZone"></div>
	</td>
</tr>
<tr>
	<th>转单</th><td id="forwardOrderZone">



	</td>
	</tr>
	</table>
</form>

